home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #14
/
Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO
/
math
/
maca_101.zip
/
ASSIGN.DEM
< prev
next >
Wrap
Text File
|
1996-01-30
|
3KB
|
107 lines
;ASSIGN.DEM
;DEMO FILE FOR MASSCALC VERSION 1.00
;WRITTEN BY: Ralph W. Reid
;This file may only be distributed in its unmodified form.
;
;DESCRIPTION: This file primarily demonstrates value assignments.
;
;For the latest releases of MASSCALC and other software created by
;Ralph W. Reid, see http://www2.athenon.com/~rreid/products/00-index.html.
;
;HOW TO USE THIS FILE: This file may be piped into MASSCALC, and its
;output displayed as follows:
;TYPE ASSIGN.DEM | MASSCALC | MORE
;This file may be redirected into MASSCALC and its output displayed
;as follows:
;MASSCALC < ASSIGN.DEM | MORE
;These two commands should be run from the operating system prompt.
;single element assignments (variable need not be dimensioned)
var1 = 8;
var2 = sin (_pi_2);
var3 = 5 * 100 / log (1e5) / log_b (2, 4) - 49 * sqrt (2);
var4 = root_secant (x, 1, 2, x - sqrt (2));
print: "var1 =" var1
print: "var2 =" var2
print: "var3 =" var3
print: "var4 =" var4
;assign individual array elements one by one
create array: vars [4];
vars [1] = 8;
vars [2] = sin (_pi_2);
vars [3] = 5 * 100 / log (1e5) / log_b (2, 4) - 49 * sqrt (2);
vars [4] = root_secant (x, 1, 2, x - sqrt (2));
print: "vars [1] =" vars [1]
print: "vars [2] =" vars [2]
print: "vars [3] =" vars [3]
print: "vars [4] =" vars [4]
print: "complete vars array:"
vars;
;assign all array elements in one line
vars = 2, 4, 6, 8;
print:
print: "After single line assignment, vars:"
vars;
;use the array to assign new values to itself
vars = vars / 2;
print:
print: "After vars = vars / 2, vars:"
vars;
;show lists of derivatives
create array: y [1, 5];
create array: y' [1, 5];
create array: y'' [1, 5];
create array: y''' [1, 5];
print:
print: "Using lists to assign derivatives to other lists:"
;start with values from x^2 spaced at an interval of 1
y = 0, 1, 4, 9, 16;
y' = derive_list (1, y);
y'' = derive_list (1, y');
y''' = derive_list (1, y'');
;output the results
print: "y, y', y'', and y''':" y, y', y'', y'''
;put these result arrays into a single array
create array: totals [4, 5];
totals = y, y', y'', y''';
print:
print: "After putting all values into a single array, totals:" totals
;zero out the first row, element by element
totals [1, 1] = 0.0;
totals [1, 2] = 0.0;
totals [1, 3] = 0.0;
totals [1, 4] = 0.0;
totals [1, 5] = 0.0;
print:
print: "After clearing the first row, totals equals:" totals
;assign values to totals directly from equations
y = 1, 2, 3, 4, 5;
totals = y, 2*y, 3*y, 4*y;
print:
print: "After assignment directly from equations, totals equals:"
totals;
;clear old variables and arrays from memory
Delete all variables.
;assign an array values from a function
create array: pi values [2, 2];
create array: sin pi values [2, 2];
create array: cos pi values [2, 2];
;assign multiples of pi to pi array
pi values = 0, _pi / 2, _pi, 3 * _pi / 2;
;assign function values to their respective arrays
sin pi values = sin (pi values);
cos pi values = cos (pi values);
;output results
print:
print: "pi vals, sines, & cosines:" pi values, sin pi values, cos pi values